package com.spark.lola.dto.warehouse;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: DengYeJun
 * @Date: 2020/6/10 13:42
 */
public class ApiResult {
    /**
     * 状态
     */
    public String status;

    /**
     * 描述
     */
    public String message;

    /**
     * 结果
     */
    private JSONObject result;

    public <T> List<T> parse(Class<T> clazz){
        if(result==null){
            return null;
        }
        if(result.get("list")==null){
            return null;
        }
        return result.getJSONArray("list").toJavaList(clazz);
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public JSONObject getResult() {
        return result;
    }

    public void setResult(JSONObject result) {
        this.result = result;
    }
}
